package com.loto.insurance.mis.web.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.loto.insurance.mis.web.db.mapper.InsCompanyMapper;
import com.loto.insurance.mis.web.entity.InsCompany;

@Service
public class InsCompanyService {
  @Autowired
  InsCompanyMapper insCompanyMapper;

  public List<InsCompany> getActiveInsCompanyList() {
	return insCompanyMapper.findActive();
  }

  public InsCompany findActiveById(long companyId) {
	return insCompanyMapper.findActiveById(companyId);
  }

  public List<InsCompany> findAllInsCompany(Map<String, Object> params) {
	return insCompanyMapper.findAllInsCompanyPager(params);
  }

  public long findAllInsCompanyCount(Map<String, Object> params) {
	return insCompanyMapper.findAllInsCompanyPagerCount(params);
  }

  public boolean addInsCompany(InsCompany insCompany) {
	if (insCompanyMapper.findInsCompanyByName(insCompany.getCompanyName()) == null)
	  return insCompanyMapper.insertInsCompany(insCompany) > 0;
	else
	  return false;
  }

  public boolean updateInsCompany(InsCompany insCompany) {
	return insCompanyMapper.updateInsCompany(insCompany) > 0;
  }

  public InsCompany findInsCompanyById(long companyId) {
	return insCompanyMapper.findInsCompanyById(companyId);
  }
}
